﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.Finance.Querys;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;

namespace mozhi.smarterp.Finance.Finances
{
    [RemoteService]
    [Route("api/v1/settlements")]
    public class SettlementController : BaseController
    {
        private ISettlementAppService _appService;
        public SettlementController(ISettlementAppService appService)
        {
            _appService = appService;
        }

        [HttpGet]
        public async Task<List<SettlementDto>> GetAsync(SettlementQuery query)
        {
            var result = await _appService.FindAsync(query);

            return result;
        }

        [HttpPost]
        [Route("close/{period}")]
        public async Task<SettlementDto> CloseAsync(int period)
        {
            var result = await _appService.ClosePeriod(period);

            return result;
        }

        [HttpPost]
        [Route("open/{period}")]
        public async Task<SettlementDto> OpenAsync(int period)
        {
            var result = await _appService.OpenPeriod(period);

            return result;
        }
    }
}
